Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Clarinet format #1609

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft

WIP - Clarinet format #1609

wants to merge 39 commits into from

Conversation

tippenein
Copy link
Collaborator

@tippenein tippenein commented Nov 12, 2024

remaining work

  • fix pre- and post-comments
  • top level max-line breaking
  • @format-ignore comments (possibly pushed off until post-mvp)
  • LSP/VSCode integration (draft: lsp format #1632)
  • passing golden test suite

@tippenein tippenein marked this pull request as draft November 12, 2024 19:19
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 78.77814% with 198 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/clarinet-format/src/formatter/mod.rs 83.52% 145 Missing ⚠️
components/clarinet-cli/src/frontend/cli.rs 0.00% 53 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tippenein tippenein force-pushed the clarinet-format branch 2 times, most recently from 5057d1b to cefc2bf Compare December 3, 2024 00:38
@tippenein
Copy link
Collaborator Author

Giving an update here.

  1. We need a way of organizing the traversal to identify expression-blocks to wrap. Currently, you could attempt to check line lengths and wrap conditionally as you go (tried this), but it won't work easily if you need multiple wraps per block. My thought is we need a Wrap type that's just used while traversing the PSEs and checks the span column length and start_line diff to turn wrapping on or off.

  2. We need to figure out ignored_expr for skipping formatting if specified. The function that exists is basically a stub but it should be possible to reconstruct the source from the PSE spans..

  3. There's a fair amount of nested indentation that fails within golden tests (the unit tests don't test this much). I would guess that a better way of handling indentation wrapping would ease this (rather than the current attempt of passing in previous_indentation and constructing the string from that.. Very error prone.

  4. This is more of a refactor, but basically we're doing way too much arg passing. There's a branch (experiment-with-accumulator) which i attempted to use an Accumulator struct to pass around the relevant info for constructing the result but it got a bit hairy with dereferencing and ultimately stack overflowed when I got it compiling. It's probably worth looking into because it would help fix 3 implicitly with the indent dedent and newline methods on Accumulator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

2 participants